package com.zdx.yswl.ui.bean;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.baidu.mapapi.model.LatLng;
import com.zdx.yswl.tool.KStringTool;

public class BuildDetailBean extends BaseBean{
    /**
	 * 
	 */
	private static final long serialVersionUID = 5271613323562915049L;
	/**顶部图片**/
	public List<HeadImgBean>  cover ;
	/**起售价*/
	public String price ;
	/**开盘时间*/
	public String openTime ;
	/**楼盘地址*/
	public String place ;
	/**详情页 标签 数组*/
	public String[] detailLabel ;
	/**状态*/
	public String state ;
	/**主力户型*/
	public  List<HeadImgBean>  houseType ;
	
	/**地图经度*/
	public  String longitude;
	
	/**地图维度*/
	public String latitude ;
	/**电话*/
	public String telPhone ;
	
	
	
	public static BuildDetailBean getBean4JSON(JSONObject json) throws JSONException{
		BuildDetailBean bean = new BuildDetailBean();
		
		bean.price = json.getString("price");
		bean.openTime = json.getString("openTime");
		bean.place = json.getString("place");
		bean.state = json.getString("state");
		bean.longitude =  json.getString("yloc");
		bean.latitude = json.getString("xloc");
		bean.telPhone = json.getString("projectTel");
		JSONArray jsonArr = json.getJSONArray("listLabel");
		if (jsonArr != null && jsonArr.length() > 0) {
			bean.detailLabel = new String[jsonArr.length()];
			for (int i = 0; i < jsonArr.length(); i++) {
				if (KStringTool.isNotEmpty(jsonArr.getString(i))) {
					bean.detailLabel[i] = jsonArr.getString(i);
				}else{
					bean.detailLabel  = null;
				}
			}
		}
		
		bean.cover = new ArrayList<HeadImgBean>();
		JSONArray jsonCover = json.getJSONArray("cover");
		bean.cover = HeadImgBean.getListBean4JSON(jsonCover);
		JSONArray jsonHouse = json.getJSONArray("houseType");
		bean.houseType = HeadImgBean.getListBean4JSON(jsonHouse);
		
		return bean;
	}
	
}
